<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<?php session_start();
 include 'includes/bandeau_sup.php'; 
 include "../User_access/access_prof.php";
 ?>
<html>
	<head>	
		<link rel="stylesheet" type="text/css" href="includes/style.css" >
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro' rel='stylesheet' type='text/css'>
		<link href='http://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700' rel='stylesheet' type='text/css'>
	</head>
	<body>
	<header>
		<h1>Affichage de la table des compétence d'un élève</h1>
	</header>
	<div id='bloc_page'>	
		<section>
			<article style='text-align:center;border-bottom:1px solid black;'>
				<?php if (isset($_SESSION['user']['message'])) 
						{
							echo "<img src='/img/error.png' /> - ".$_SESSION['user']['message']; 
							unset($_SESSION['user']['message']);
						} 
				?>
			</article>
			<article>
				<table style="width:100%;">
					<tr>
						<td>
							<form method="post" action="tab_affiche.php">
							<?php

								include '../conf/config.php';

								mysql_connect($host,$user_select,$mdp_select)or die("impossible de se connecter"); 

								mysql_select_db("website")or die("ne peut selectioner DB");
								
								$sql="SELECT Nom, Prenom FROM user WHERE FK_statut = 2 AND valide = 1;";
								$query=mysql_query($sql);
								echo "<p>Choisir dans la liste : <select name='name_2'>";
								while($row = mysql_fetch_array($query))
								{
									echo "<option value=".utf8_decode($row['Nom']).">".utf8_decode($row['Prenom'])." ".utf8_decode($row['Nom'])."</ option>";
								}
								echo "</select>";

							?>
						</td>
						<td>
							Recherche : <input type="text" name="name" value="" id="name" />
							<input type="submit" value="Rechercher" name="envoi">
							</form>
						</td>
						<td>
							<a href="index.php">Revenir au menu</a>
						</td>
					</tr>
				</table>
			</article>
			<hr>
			<article>
						<p>
							<?php
								include '../conf/config.php';

								if (isset($_POST["envoi"]))
								{

									$nom = utf8_encode($_POST['name_2']);

									//echo $nom;

									if(isset($_POST['name']) && $_POST['name'] !== "")
									{
										$nom= utf8_encode( $_POST['name'] ); 
										//echo $nom;
									}

									
									// Connect to server and select databse.
									mysql_connect($host,$user_select,$mdp_select)or die("impossible de se connecter"); 
									mysql_select_db("website")or die("ne peut selectioner DB");
									
									
									
									$sql="SELECT evo.progression, evo.date_modif, comp.nomComp, evo.skill_validate, evo.id_evo, evo.id_user
									FROM comp, evo, user
									WHERE '$nom'=user.Nom 
									AND evo.id_comp=comp.id_comp
									AND evo.id_user=user.id_user";
									// echo $sql;
									$query=mysql_query($sql);

									$row=mysql_fetch_array($query);

									echo "Export au format CSV : <a href='csv.php?id=".$row['id_user']."'><img src='/img/export.gif' /></a>";

									echo "<table><form method='post' action='validate.php'>";

									while($row = mysql_fetch_array($query))
									{
										if ($row['progression'] != $row['skill_validate'])
											{
												echo "<tr class='non_valide'> <td>".$row['nomComp'] . "</td><td>Proposition : " .$row['progression'] . "%</td><td>Dernière valeur validée : " .$row['skill_validate'] . "%</td><td>En date du : " .$row['date_modif']. "</td><td>Valider : <input type='checkbox' name='valid[".$row['id_evo']."]' value='1' checked></td></tr>";
											}
										else 
											{
												echo "<tr> <td>".$row['nomComp'] . "</td><td> </td><td>Dernière valeur validée : " .$row['skill_validate'] . "%</td><td>En date du : " .$row['date_modif']. "</td><td></td></tr>";
											}
									}
									echo "</table><input type='submit' name='valider'></form>";
									echo "</table></div> ";

								}							
								?>
						</p>
			</article> 
		</section>
		</div>
		<?php include "includes/footer.php" ?>
	</body>
</html>